<?php
namespace Map;
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/5/22 0022
 * Time: 11:28
 */

class Map {

    protected static $key = 'MI3BZ-CRJWJ-7NRFZ-FOSVL-KRZC6-AHFRS';

    /**
     * 根据地址获取经纬度信息
     * @param $address
     * @return mixed
     */
    public static function getLngLat($address) {
        $url = 'http://apis.map.qq.com/ws/geocoder/v1/?address=' . $address . '&key=' . self::$key;
        $data = get_data($url);
        return $data;
    }

    /**
     * 根据经纬度获取静态图片
     * @param $location
     * @return string
     */
    public static function getStaticMapUrlByLngLat($location) {
        return $url = 'http://apis.map.qq.com/ws/staticmap/v2/?center='. $location['lat'] .','. $location['lng'] .'&key='. self::$key .'&size=500*400&zoom=14&markers=color:blue|label:A|'. $location['lat'] .','. $location['lng'];
    }

    /**
     * 经纬度转地址
     * @param $location
     * @return mixed
     */
    public static function getGeocoder($location) {
        $url = 'http://apis.map.qq.com/ws/geocoder/v1/?location=' . $location . '&get_poi=1&key=' . self::$key;
        $data = get_data($url);
        return $data;
    }
}